package junior.DFS;

public class 排列小球 {

    static int arr[] = {3,6,0};
    static int count = 0;

    public static void main(String[] args) {

        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        f(sum, 0, -1);
        System.out.println(count);

    }

    private static void f(int sum, int x, int last) {
        if (sum == 0) {
            count++;
            return;
        }
        for (int i = 0; i < arr.length; i++) {
            if (i == last)
                continue;
            for (int j = x + 1; j <= arr[i] && j <= sum; j++) {
                arr[i] = arr[i] - j;
//                for (int k = 0; k < arr.length; k++) {
//                    System.out.print(arr[k]+"\t");
//                }
//                System.out.println();
                f(sum - j, j, i);
                arr[i] = arr[i] + j;
            }
        }
    }

}
